package cn.yunhe.action;

import cn.yunhe.entity.Admin;
import cn.yunhe.service.AdminService;
import cn.yunhe.service.UpAdminService;
import cn.yunhe.util.BaseUtil;
import lombok.Data;
import net.sf.json.JSONArray;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@Data
public class AdminAction extends BaseUtil {
    private String result;
    private int id;

    public String showAdmin() throws IOException {
        AdminService adminService = new AdminService();
        JSONArray data = adminService.searchAdmin();
        this.result = data.toString();
        return "success";
    }

    public String upAdmin() {
        UpAdminService upAdminService = new UpAdminService();
        int row = upAdminService.upAdmin(id);
        if (row > 0) {
            return "success";
        } else {
            return "fail";
        }
    }
}
